﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.ContentManagement.Drivers;
using Orchard.Localization;

namespace TekFlow.FamilyTree.Drivers
{
    public class FamilyTreeDriver: ContentPartDriver<Models.FamilyTreePart>
    {
        public FamilyTreeDriver()
        {
            T = NullLocalizer.Instance;
            
        }

        public Localizer T { get; set; }

        protected override DriverResult Display(Models.FamilyTreePart part, string displayType, dynamic shapeHelper)
        {

            return ContentShape("Parts_FamilyTree", () => shapeHelper.Parts_FamilyTree(
                FamilyName: part.FamilyName,
                Url: part.Url,
                FamilyMemberId: part.FamilyMemberId));
        }

        protected override DriverResult Editor(Models.FamilyTreePart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_FamilyTree_Edit",
                () => shapeHelper.EditorTemplate(TemplateName: "Parts/FamilyTree", Model: part, Prefix: Prefix)
                    );
        }

        protected override DriverResult Editor(Models.FamilyTreePart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper)
        {
            bool success = updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
    
}